<template>
  <div>
    <el-row :gutter="22">
      <el-col :span="22" :offset="1">
        <div class="drg_left">
          <el-card class="box-card">
            <el-form ref="form" :model="form" label-width="90px">
              <el-row :gutter="20">
                <el-col :span="6">
                  <el-form-item label="主诊断:">
                    <el-input v-model="form.mainDiagnosisCode" placeholder="请输入主诊断编码"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="其他诊断:">
                    <el-input v-model="form.nextDiagnosisCode" placeholder="多个诊断用逗号连接"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="手术/操作:">
                    <el-input v-model="form.operationCode" placeholder="请输入手术/操作编码"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="性别:">
                    <el-radio-group v-model="form.sex">
                      <el-radio v-model="form.sex" label="M">男</el-radio>
                      <el-radio v-model="form.sex" label="F">女</el-radio>
                    </el-radio-group>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="20">
                <el-col :span="6">
                  <el-form-item label="年龄:">
                    <el-input v-model="form.age" placeholder="请输入年龄(岁)"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="新生儿年龄:">
                    <el-input v-model="form.newbornAge" placeholder="请输入新生儿年龄(天)"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="新生儿体重:">
                    <el-input v-model="form.newbornWeight" placeholder="请输入新生儿体重(g)"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="住院天数:">
                    <el-input v-model="form.daysStay" placeholder="请输入住院天数(天)"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="20">
                <el-col :span="6">
                  <el-form-item label="住院费用:">
                    <el-input v-model="form.chargeStay" placeholder="请输入住院费用(元)"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="离院方式">
                    <el-radio-group v-model="form.leavingWay">
                      <el-radio v-model="form.leavingWay" label="5">正常医嘱</el-radio>
                      <el-radio v-model="form.leavingWay" label="7">死亡/转院</el-radio>
                      <el-radio v-model="form.leavingWay" label="9">不区分</el-radio>
                    </el-radio-group>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item>
                    <el-button type="primary" @click="onSubmit" round>查询</el-button>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </el-card>
        </div>
      </el-col>
    </el-row>
    <el-row :gutter="22">
      <el-col :span="22" :offset="1">
        <div class="drg_left">
          <el-card class="box-card">
            <el-steps :active="list.length">
              <el-step v-for="item in list" :key="item.currentIndex" :title="item.curName" :description="item.remark">{{item.result}}</el-step>
            </el-steps>
          </el-card>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<style lang="scss">
.drg_left {
  margin-top: 20px;
}
</style>

<script>
import { drgsQuery } from '../../api/pt-visit'

export default {
  data () {
    return {
      input: '',
      form: {
        mainDiagnosisCode: '',
        nextDiagnosisCode: '',
        operationCode: '',
        sex: 'M',
        age: '',
        newbornAge: '',
        newbornWeight: '',
        daysStay: '',
        chargeStay: '',
        leavingWay: '5'
      },
      list: []
    }
  },
  methods: {
    onSubmit () {
      const that = this
      drgsQuery({
        mainDiagnosisCode: this.form.mainDiagnosisCode,
        nextDiagnosisCode: this.form.nextDiagnosisCode,
        operationCode: this.form.operationCode,
        sex: this.form.sex,
        age: this.form.age,
        newbornAge: this.form.newbornAge,
        newbornWeight: this.form.newbornWeight,
        daysStay: this.form.daysStay,
        chargeStay: this.form.chargeStay,
        leavingWay: this.form.leavingWay
      }).then(res => {
        res.forEach(x => {
          x.curName = '步骤' + x.currentIndex
          x.remark = x.remark + x.result
        })
        that.list = res
      })
    }
  }
}
</script>
